package com.example.helloword;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;

import com.example.helloword.utils.ConfigTile;

@SuppressLint("UseSparseArrays")
public class GuessActivity extends Activity {

	private ConfigTile configTile;

	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guess_the_figure_hw);
        this.configTile = (ConfigTile)getIntent().getSerializableExtra("ConfigTile");
        configTile.initialize(GuessActivity.this);

        TableLayout tbl=(TableLayout) findViewById(R.id.tlTiles);
        TableRow.LayoutParams params1 = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, 1.0f);
        createImageViewTiles(tbl, params1);
    }

	private void createImageViewTiles(TableLayout tbl, TableRow.LayoutParams params1) {
		int index = 0;
        for(int iRow = 0; iRow < ConfigTile.CANT_ROWS; iRow++) {
        	TableRow row=new TableRow(this);
        	row.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        	row.setPadding(5, 5, 5, 5);
        	for(int iTile=0; iTile < ConfigTile.CANT_TILES_X_ROWS; iTile++) {
        		row.addView(configTile.getImageView(index, params1));
        		index++;
        	}
        	tbl.addView(row);
        }
	}

}